﻿using Ecommerce.DTO;
using Ecommerce.tbCommodity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace Ecommerce
{
    public class CommodityInfoService : CrudAppService
    <tbCommodityInfo, tbCommodityInfoDto, Guid, tbCommodityInfoFind,CreateUpdateCommodityInfoDto>
    ,tbCommodityInfoDtoFindcs
    {
        public CommodityInfoService(IRepository<tbCommodityInfo, Guid> repository): base(repository)
        {

        }

        [Obsolete]
        protected override IQueryable<tbCommodityInfo> CreateFilteredQuery(tbCommodityInfoFind input)
        {
            return base.CreateFilteredQuery(input).WhereIf(!string.IsNullOrEmpty(input.Name), b => b.CommodityName.Contains(input.Name))
                .Where(d => d.CommodityDisplay.Equals(input.CommodityDisplay))
                .WhereIf(!string.IsNullOrEmpty(input.CommodityTypeId),a=>a.CommodTypeId.Equals(input.CommodityTypeId));
        }
    }

     
    public class CommodityTypeAppService :
        CrudAppService<
            tbCommodityType, //The Book entity
            tbCommodityTypeDto, //Used to show books
            Guid, //Primary key of the book entity
            PagedAndSortedResultRequestDto, //Used for paging/sorting
            CreateUpdatetbCommodityTypeDto>, //Used to create/update a book
        ICommodityTypeService //implement the IBookAppService
    {
        public CommodityTypeAppService(IRepository<tbCommodityType, Guid> repository)
            : base(repository)
        {

        }
    }
}
